package com.streaming.project.spark.utils

import java.util.Date

import org.apache.commons.lang3.time.FastDateFormat

/**
  * 创建一个时间工具类
  */

object DateUtils {

  // SimpleFormat 是线程不安全的！！！

  val YYYYMMDDMMSS_FORMAT= FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss")

  // 输出格式
  val TARGET_FORMAT = FastDateFormat.getInstance("yyyyMMddHHmmss")


  def getTime(time:String) ={

      YYYYMMDDMMSS_FORMAT.parse(time).getTime

  }

  def parseToMinute(time:String) ={

    TARGET_FORMAT.format(new Date(getTime(time)))
  }


  def main(args: Array[String]): Unit = {

    println(parseToMinute("2019-03-02 11:59:00"))


  }



}
